#
# Component Makefile
#
# This file is part of SKUMLI.
# Copyright (C) 2010 Davide Giuseppe Monaco (black.ralkass@gmail.com)
#
# SKUMLI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# SKUMLI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

SOURCES = $(shell ls alu*) $(shell ls cache*) $(shell ls control_unit*) $(shell ls mux*) $(shell ls ram*) $(shell ls regfile*) $(shell ls register*) $(shell ls sign_ext*) $(shell ls victim*)
DATASRC = $(shell ls mem_hierarchy*) $(shell ls datapath*)
OBJECTS = $(SOURCES:.vhd=.o)
DATAOBJ = $(DATASRC:.vhd=.o)
TESTS   = $(OBJECTS:_tb.o=.test)
DTESTS  = $(DATAOBJ:_tb.o=.test)

IEEE    = --ieee=synopsys -fexplicit

all: $(OBJECTS) $(DATAOBJ) $(TESTS) $(DTESTS)
#all: $(OBJECTS) $(TESTS)

%.test: %_tb.o
	ghdl -e $(IEEE) `echo $< | sed -r "s/\.o//"`

%.o: %.vhd
	ghdl -a $(IEEE) $<

clean:
	ghdl --clean
	rm -f *.cf
	rm -f *~
	rm -f *.vcd
